import {
	baseUrl,
} from "./url.js"

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// 登录
	let login = (params = {}) => vm.$u.post(baseUrl + '/auth/admin/login', params);
	let userInfo = (params = {}) => vm.$u.post(baseUrl + '/account/current', params);
	let modifyPassword = (params = {}) => vm.$u.post(baseUrl + '/account/modifyPassword', params);
	let dictDamage = () => vm.$u.post(baseUrl + '/dict/select/damage');
	let dictRepair = () => vm.$u.post(baseUrl + '/dict/select/repair');
	let dictSelect = (data) => vm.$u.post(baseUrl + '/dict/select/' + data);
	// 查询人员列表
	let accountSelect = () => vm.$u.post(baseUrl + '/account/select');
	// 查询维保内容列表
	let getContentList = (params = {}) => vm.$u.post(baseUrl + `/dict/select/EQ_CATEGORY_MT/${params.parentId}`);

	// 维修安装
	// 新增
	let repairSave = (params = {}) => vm.$u.post(baseUrl + '/repair/saveOrUpdate', params);
	// 回访
	let repairFollow = (params = {}) => vm.$u.post(baseUrl + '/repair/updateFollow', params);
	// 分页
	let repairQuery = (params = {}) => vm.$u.post(baseUrl + '/repair/query', params);
	// 详情
	let repairGetOne = (params = {}) => vm.$u.post(baseUrl + `/repair/getOne?id=${params.id}`, params);


	// 维保
	// 新增
	let maintenanceSave = (params = {}) => vm.$u.post(baseUrl + '/maintenance/saveOrUpdate', params);
	// 分页
	let maintenanceQuery = (params = {}) => vm.$u.post(baseUrl + '/maintenance/query', params);
	// 详情
	let maintenanceGetOne = (params = {}) => vm.$u.post(baseUrl + `/maintenance/getOne?id=${params.id}`, params);

	// 设备
	// 列表
	let equipmentQuery = (params = {}) => vm.$u.post(baseUrl + '/equipment/query', params);
	// 详情
	let equipmentGetOne = (params = {}) => vm.$u.post(baseUrl + `/equipment/getOne?id=${params.id}`, params);
	let getLastRepairInfo = (params = {}) => vm.$u.post(baseUrl + `/equipment/getLastRepairInfo?id=${params.id}`,
		params);
	let getLastMaintenanceInfo = (params = {}) => vm.$u.post(baseUrl +
		`/equipment/getLastMaintenanceInfo?id=${params.id}`, params);


	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		login,
		userInfo,
		modifyPassword,
		dictDamage,
		dictRepair,
		repairSave,
		repairFollow,
		repairQuery,
		repairGetOne,
		maintenanceSave,
		maintenanceQuery,
		maintenanceGetOne,
		equipmentQuery,
		equipmentGetOne,
		getLastRepairInfo,
		getLastMaintenanceInfo,
		dictSelect,
		accountSelect,
		getContentList,

	};
}

export default {
	install
}